#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

const int NM = 1e5 + 5;
const int L = 1e6 + 5;

struct car
{
    int d , v , a;
};


int t;
int n , m , l , v;
car cars[NM];
vector<vector<int> > beijiancedao;
int p[NM];
int ptong[L];

void ischaosu(int i)
{
    if (cars[i].v < ::v)
    {
        if (cars[i].a <= 0)
        {
            return ;
        }
        else
        {
            int tmp = (v * v - cars[i].v * cars[i].v) / (2 * cars[i].a);
            tmp += cars[i].d;
            tmp ++;
            for (int j = tmp ; j <= l ; j ++)
            {
                if (ptong[j] == 1)
                {
                    beijiancedao[i].push_back(j);
                }
            }
            return ;
        }
    }
    else if (cars[i].v > ::v)
    {
        if (cars[i].a >= 0)
        {
            for (int j = cars[i].d ; j <= l ; j ++)
            {
                if (ptong[j] == 1)
                {
                    beijiancedao[i].push_back(j);
                }
            }
            return ;
        }
        else
        {
            //判断什么时候低于限速
            int tmp = (v * v - cars[i].v * cars[i].v) / (2 * cars[i].a);
            for (int j = cars[i].d ; j < tmp ; j ++)
            {
                if (ptong[j] == 1)
                {
                    //fixme: push_back
                    beijiancedao[i].push_back(j);
                }
            }
        }
    }
    else
    {
        if (cars[i].a > 0)
        {
            for (int j = cars[i].d + 1 ; j <= l ; j ++)
            {
                if (ptong[j] == 1)
                {
                    beijiancedao[i].push_back(j);
                }
            }
            return ;
        }
        else
        {
            return ;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false) , cin.tie(nullptr) , cout.tie(nullptr);
    freopen("detect.in" , "r" , stdin);
    freopen("detect.out" , "w" , stdout);
    cin >> t;
    while (t --)
    {
        cin >> n >> m >> l >> v;
        for (int i = 1 ; i <= n ; i ++)
        {
            cin >> cars[i].d >> cars[i].v >> cars[i].a;
        }
        for (int i = 1 ; i <= m ; i ++)
        {
            cin >> p[i];
            ptong[p[i]] = 1;
        }
        vector<int> t(1 , 0);
        for (int i = 1 ; i <= n ; i ++)
        {
            beijiancedao.push_back(t);
            ischaosu(i);
        }
    }
    return 0;
}
